home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln0486.arc
/
MENU.LT2
< prev
next >
Wrap
Text File
|
1986-04-06
|
2KB
|
57 lines
stty -echo; cat - > MEN.H; stty echo
#define DISPLAY 3 /* class types */
#define INTEGER 2
#define STRING 1
char menline[LINELEN]; /* this holds any parameters */
struct menu {
int noitems; /* how many items this menu line */
char items[10][20]; /* string array for the items themselves */
int next[10]; /* pointer to either the next menu line */
/* or, if negative, to function in pointer array */
int class[10]; /* class is used to determine
what kind of value to pass to function,
or whether to even call one, as follows:
DISPLAY - show menu only, call no function
INTEGER - pass an integer to function
STRING - pass a string pointer to function
*/
} men[] = { /* here is where you initialize the menu items
since we're dealing with a static array size,
you've got to enter null pointers and zeroes, as
appropriate. The data here is only a sample.
The negative "next" items index into the function
pointer array and the help array; if they were positive
numbers, they would index into another menu line */
/* 0 */
3,"A test","One","Two","","","","","","","",
-1,-2,-3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
/* all the functions you're going to link in will require declaration */
extern int test();
extern int one();
extern int two();
/* convenience only, but may be useful later */
typedef int (*PF)();
/* now all function names must be arrayed. Note the zeroth element cannot
be used */
PF func[] = {
test,
test,
one,
two};
/* here's the help which is also indexed along with the function pointers */
char menu_help[][COLS] = {
" ",
"first item",
"second item",
"third item"};
ng with the function pointers */
char menu_help[][COLS] = {
" ",
"first item",